package com.isdepci.project.factor.controller;

import java.util.List;

import com.isdepci.common.constant.UserConstants;
import com.isdepci.common.utils.StringUtils;
import com.isdepci.project.factor.domain.CategorizeInfo;
import com.isdepci.project.factor.utils.FactorRedisUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.factor.domain.StandardStage;
import com.isdepci.project.factor.service.IStandardStageService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 项目标准阶段管理Controller
 *
 * @author isdepci
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/factor/standardStage")
public class StandardStageController extends BaseController {
    @Autowired
    private IStandardStageService standardStageService;

    /**
     * 查询项目标准阶段管理列表
     */
    @PreAuthorize("@ss.hasPermi('factor:standardStage:list')")
    @GetMapping("/list")
    public TableDataInfo list(StandardStage standardStage) {
        startPage();
        List<StandardStage> list = standardStageService.selectStandardStageList(standardStage);
        return getDataTable(list);
    }

    /**
     * 获取项目标准阶段管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('factor:standardStage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(standardStageService.selectStandardStageById(id));
    }

    /**
     * 新增项目标准阶段管理
     */
    @PreAuthorize("@ss.hasPermi('factor:standardStage:add')")
    @Log(title = "项目标准阶段管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StandardStage standardStage) {
        return (standardStageService.insertStandardStage(standardStage));
    }

    /**
     * 修改项目标准阶段管理
     */
    @PreAuthorize("@ss.hasPermi('factor:standardStage:edit')")
    @Log(title = "项目标准阶段管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StandardStage standardStage) {
        return (standardStageService.updateStandardStage(standardStage));
    }

    /**
     * 删除项目标准阶段管理
     */
    @PreAuthorize("@ss.hasPermi('factor:standardStage:remove')")
    @Log(title = "项目标准阶段管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return (standardStageService.deleteStandardStageById(id));
    }


    @Log(title = "分类管理", businessType = BusinessType.CLEAN)
    @DeleteMapping("/clearCache")
    public AjaxResult clearCache() {
        FactorRedisUtils.clearStandardStageCache();
        return AjaxResult.success();
    }
}
